local duanbing = fk.CreateSkill {

  name = "joy__duanbing",

  tags = {  },

}



duanbing:addEffect(fk.AfterCardTargetDeclared, {
  name = "joy__duanbing",
  anim_type = "offensive",
  events = {fk.AfterCardTargetDeclared},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(duanbing.name) and data.card.trueName == "slash"
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = {}
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if not table.contains(data:getAllTargets(), p.id) and player:distanceTo(p) == 1 and not player:isProhibited(p, data.card) then
        table.insertIfNeed(targets, p.id)
      end
    end
    if #targets > 0 then
      local tos = room:askForChoosePlayers(player, targets, 1, 1, "#joy__duanbing-choose", duanbing.name, true)
      if #tos > 0 then
        event:setCostData(self, tos[1])
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    table.insert(data.tos, {event:getCostData(self)})
  end,
})

duanbing:addEffect(fk.TargetSpecified, {
  name = "#joy__duanbing_effect",
  mute = true,
  events = {fk.TargetSpecified},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(duanbing.name) and data.card.trueName == "slash"
    and player:distanceTo(player.room:getPlayerById(data.to)) == 1 and player:usedSkillTimes(duanbing.name, Player.HistoryTurn) == 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    data.fixedResponseTimes = data.fixedResponseTimes or {}
    data.fixedResponseTimes["jink"] = 2
  end,
})

return duanbing